/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lt.cj.core.server;

import org.lt.cj.config.entities.ConfigModel;
import org.lt.cj.core.LinkDB;
import org.lt.cj.core.Queue;
import org.lt.cj.core.Seed;
import org.lt.cj.core.Task;

/**
 *
 * @author Administrator
 */
public class ShutdHookThread extends Thread {

    private ConfigModel configModel;
    private LinkDB linkDB;
    private Task task;

    public ShutdHookThread(Task task) {
        this.task = task;
    }

    public ShutdHookThread(ConfigModel configModel, LinkDB linkDB) {

        this.configModel = configModel;
        this.linkDB = linkDB;
    }

    @Override
    public void run() {

        this.configModel = task.getConfigModel();
        this.linkDB = task.getLinkDB();

//        synchronized (linkDB) {
        Queue<Seed> queue = linkDB.getUnVisitedUrl();
        String[] urls = new String[queue.getCount()];
        System.out.println(urls.length);
        for (int i = 0; i < urls.length; i++) {
//            urls[i] = queue.getT(i);
        }
//        configModel.setUrls(urls);
//        }
//        ServerModel serverModel = ServerModel.getInstance();
//        serverModel.saveTask(configModel);
    }
}
